#pragma once
#include "const.h"
#include"CSession.h"
#include"AsioIOServicePool.h"
class CServer:public std::enable_shared_from_this<CServer>
{
public:
	CServer(boost::asio::io_context& ioc,short port);
	~CServer();
	void ClearSession(std::string);
private:
	tcp::acceptor _acceptor;
	boost::asio::io_context& _ioc;
	short _port;
	std::map<std::string, std::shared_ptr<CSession>>_sessions;
	std::mutex _mutex;

	void HandleAccept(std::shared_ptr<CSession>, const boost::system::error_code& ec);
	void StartAccept();

};

